<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<style type="text/css">
#eventT {
	width: 100%;
	border: 1px solid #999999;
}
#eventT td {
	border: 1px solid #dddddd;
}
#eventT input[type=text] {
	width: 99%;
	height: 30px;
}
#bannerT {
	width: 99%;
	text-align: center;
}
</style>

<script src="resources/js/fileUpload/webFileUpload.js"></script>
<script src="//cdn.ckeditor.com/4.4.2/full/ckeditor.js"></script><!-- 웹에디터 ckeditor CDN방식 연결 -->
<script src="resources/js/skins/fileSkin.js"></script>
<script src="resources/js/etc/imagePreview.js"></script>
<script type="text/javascript">

$(function() {
	CKEDITOR.replace( 'ev_content',  {
		width: '100%',
		height: '350px'
	});
	
	CKEDITOR.instances.editor1.setData($("#before_content").html());
	
	$("input[name=ev_startdate]").datepicker();
	$("input[name=ev_enddate]").datepicker();
	
	setFileSkin();
	setImageFile({
		targetId: "bannerFile",
		previewId: "preview",
		previewWidth: 512,
		previewHeight: 120
	});
});


function checkInput() {
	if( $("input[name=ev_subject]").val() == "" ) {
		alert("제목을 입력하세요.");
		return false;
	} else if( $("input[name=ev_startdate]").val() == "" ) {
		alert("시작일을 선택하세요.");
		return false;
	} else if( $("input[name=ev_enddate]").val() == "" ) {
		alert("종료일을 선택하세요.");
		return false;
	} else if( CKEDITOR.instances.editor1.getData() == "" ) {
		alert("본문 내용을 입력하세요.");
		return false;
	}
	
	return true;
}

function deleteBeforePreview() {
	alert("1");
	$("#beforePreview").html("");
}
	
</script>

</head>
<body>

<div id="before_content" style="display:none;">${resultClass.ev_content }</div>

<h2>Event Page - 수정 하기</h2>

<!-- 웹 에디터 추가 부분 from 안성모 -->
<form action="modifyEvent.ga" method="post" enctype="multipart/form-data" autocomplete="off" onsubmit="return checkInput()">
	<!-- ev_no -->
	<input type="hidden" name="ev_no" value="${resultClass.ev_no }"/>
	
	<table id="eventT" cellpadding="0" cellspacing="0">
		<tr>
			<td class="table_titleHeight" style="width:10%;">제목</td>
			<td style="width:50%;"><input type="text" name="ev_subject" value="${resultClass.ev_subject }"/></td>
			<td class="table_titleHeight" style="width:8%;">시작일</td>
			<td><input type="text" name="ev_startdate" value="${resultClass.ev_startdate }" style="cursor:pointer;" readonly/></td>
			<td class="table_titleHeight" style="width:8%;">종료일</td>
			<td><input type="text" name="ev_enddate" value="${resultClass.ev_enddate }" style="cursor:pointer;" readonly/></td>
		</tr>
	</table>
	<br/>
	
	<table id="contentT" cellpadding="10" cellspacing="0">
		<tr>
			<td colspan="2" rowspan="3" style="width:60%;">
				<textarea name="ev_content" id="editor1" rows="10" cols="80"></textarea>
			</td>
			<td style="width:40%;" valign="top" style="vertical-align:top;">
				
				<table id="bannerT" cellpadding="0" cellspacing="0">
					<tr>
						<td class="table_titleHeight" style="width:50%;">베너 이미지 등록 (640*150)</td>
						<td style="width:50%;"><input type="file" name="bannerFile" id="bannerFile"/></td>
					</tr>
					<tr>
						<td colspan="2" style="width:512px;height:120px;border:1px solid #aaaaaa;">
							<div id="preview">
									<img src="resources/images/uploadFiles/${resultClass.ev_image }"
										style="width:512px;height:120px;"
										id="img_preview"
									/>
							</div>
						</td>
					</tr>
				</table>
				
			</td>
		</tr>
		<tr style="height:80px;">
			<td><input type="button" value="본문 이미지 추가+" onclick="file_plus('result')"/></td>
		</tr>
		<tr>
			<td valign="top" style="vertical-align:top;"><div id="result" style="height:280px;overflow:auto;"></div></td>
		</tr>
	</table>
    <br/>
    
    <div style="text-align:center;">
    	<input type="button" value="취소" onclick="location.href='eventList.ga'"/>
    	<input type="submit" class="bigBtn" value="수정 완료" />
    </div>
</form>

</body>
</html>